// **************************************************************
// Com ++ Framework by the C++ World
// Please report defects: mailto:compp@cplusplusworld.com
// Please visit: http://www.cplusplusworld.com/socketlibrary.html
// **************************************************************
#include "SysPlusPlus/GenCfg.h"

compp::GenCfg *compp::GenCfg::instance_ = NULL;


compp::GenCfg *compp::GenCfg::Instance() {

    if (instance_ == NULL) {
      instance_ = new GenCfg();
    }
    return instance_;
}


compp::GenCfg::GenCfg() {

    this->FillDefaults();
}

void compp::GenCfg::FillDefaults() {

  // Comm
  SetCommWriteTimeout        (compp::StdCommWriteTimeout);
  SetCommReadTimeout         (compp::StdCommReadTimeout);
  SetCommFDAttached          (compp::StdCommFDAttached);

  // Socket
  SetCommLingerTime          (compp::StdCommLingerTime);
  SetCommUseDNS              (compp::StdCommUseDNS);
  SetCommMaxNumBytesToRead   (compp::StdCommMaxNumBytesToRead);

  // Socket Tcp
  SetCommOptAsync            (compp::StdCommOptAsync);
  SetCommOptAsyncConnect     (compp::StdCommOptAsyncConnect);
  SetCommOptTcpNoDelay       (compp::StdCommOptTcpNoDelay);
  SetCommBacklog             (compp::StdCommBacklog);

}

void compp::GenCfg::SetCommWriteTimeout (int val) {
  this->CommWriteTimeout = val;
}

int compp::GenCfg::GetCommWriteTimeout () {
  return CommWriteTimeout;
}

void compp::GenCfg::SetCommReadTimeout (int val){
  this->CommReadTimeout = val;
}

int compp::GenCfg::GetCommReadTimeout (){
  return this->CommReadTimeout;
}

void compp::GenCfg::SetCommFDAttached (bool val){
  this->CommFDAttached = val;
}

bool compp::GenCfg::GetCommFDAttached (){
  return this->CommFDAttached;
}

void compp::GenCfg::SetCommOptAsync (bool val){
  this->CommOptAsync = val;
}

bool compp::GenCfg::GetCommOptAsync (){
  return this->CommOptAsync;
}

void compp::GenCfg::SetCommOptAsyncConnect (bool val){
  this->CommOptAsyncConnect = val;
}

bool compp::GenCfg::GetCommOptAsyncConnect (){
  return this->CommOptAsyncConnect;
}

void compp::GenCfg::SetCommLingerTime (int val){
  this->CommLingerTime = val;
}

int compp::GenCfg::GetCommLingerTime (){
  return this->CommLingerTime;
}

void compp::GenCfg::SetCommUseDNS (bool val){
  CommUseDNS = val;
}

bool compp::GenCfg::GetCommUseDNS (){
  return this->CommUseDNS ;
}

void compp::GenCfg::SetCommMaxNumBytesToRead (int val){
  this->MaxNumBytesToRead = val;
}

int compp::GenCfg::GetCommMaxNumBytesToRead (){
  return this->MaxNumBytesToRead;
}

void compp::GenCfg::SetCommBacklog (int val){
  this->Backlog = val;
}

int compp::GenCfg::GetCommBacklog (){
  return this->Backlog;
}


void compp::GenCfg::SetCommOptTcpNoDelay (bool val) {
  this->CommOptTcpNoDelay = val;
}

bool compp::GenCfg::GetCommOptTcpNoDelay () {
  return this->CommOptTcpNoDelay;
}
